package com.ruoyi.web.controller.laiqianba.application;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.applet.enums.AppletEnum;
import com.ruoyi.applet.enums.StatusEnum;
import com.ruoyi.laiqianba.service.IAddressInfoService;
import com.ruoyi.laiqianba.service.IApplicationInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.ApplicationInfo;
import com.ruoyi.web.wrapper.ApplicationInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 应用包管理Controller
 * 
 * @author ruoyi
 * @date 2025-09-04
 */
@RestController
@RequestMapping("/application/applicationInfoData")
public class ApplicationInfoController extends BaseController
{
    @Autowired
    private IApplicationInfoService applicationInfoService;
    @Autowired
    IAddressInfoService  addressInfoService;

    @GetMapping("/extDate")
    public AjaxResult extData(){
        JSONObject returnData = new JSONObject();
        returnData.put("address", addressInfoService.getProvinceAll());
        return AjaxResult.success(returnData);
    }

    /**
     * 查询应用包管理列表
     */
    @PreAuthorize("@ss.hasPermi('application:applicationInfoData:list')")
    @GetMapping("/list")
    public TableDataInfo list(ApplicationInfo applicationInfo)
    {
        startPage();
        List<Map<String, Object>> list = applicationInfoService.selectApplicationInfoMapList(applicationInfo);
        list = new ApplicationInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出应用包管理列表
     */
    @PreAuthorize("@ss.hasPermi('application:applicationInfoData:export')")
    @Log(title = "应用包管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ApplicationInfo applicationInfo)
    {
        List<ApplicationInfo> list = applicationInfoService.selectApplicationInfoList(applicationInfo);
        ExcelUtil<ApplicationInfo> util = new ExcelUtil<ApplicationInfo>(ApplicationInfo.class);
        util.exportExcel(response, list, "应用包管理数据");
    }

    /**
     * 获取应用包管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('application:applicationInfoData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(applicationInfoService.selectApplicationInfoById(id));
    }

    /**
     * 新增应用包管理
     */
    @PreAuthorize("@ss.hasPermi('application:applicationInfoData:add')")
    @Log(title = "应用包管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ApplicationInfo applicationInfo)
    {
        return toAjax(applicationInfoService.insertApplicationInfo(applicationInfo));
    }

    /**
     * 修改应用包管理
     */
    @PreAuthorize("@ss.hasPermi('application:applicationInfoData:edit')")
    @Log(title = "应用包管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ApplicationInfo applicationInfo)
    {
        return toAjax(applicationInfoService.updateApplicationInfo(applicationInfo));
    }

    /**
     * 删除应用包管理
     */
    @PreAuthorize("@ss.hasPermi('application:applicationInfoData:remove')")
    @Log(title = "应用包管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(applicationInfoService.deleteApplicationInfoByIds(ids));
    }
}
